//
//  DKHomeLoanScuessController.m
//  DanKU
//
//  Created by 吴斌 on 2023/12/7.
//

#import "DKHomeLoanScuessController.h"
#import "DKHomeLoanScoreAlertView.h"
@interface DKHomeLoanScuessController ()
@property (nonatomic, strong)UIButton * dk_LoanScuessBtn;
@end
@implementation DKHomeLoanScuessController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = UIColor.whiteColor;
    [self dk_addSubView];
    [self makeNavBack];
    
    [DKPublicHttp apiUserBrhavRecordForAPI:@{} withPageName:DK_LoanSuccess withAction:DK_ActionEnter complete:^{
            
    } fail:^{
            
    }];
}
- (void)dk_addSubView{
    UILabel *loanScuessHeadLab = [[UILabel alloc] init];
    loanScuessHeadLab.textColor = DK_Hex(@"#4566FF");
    loanScuessHeadLab.font = DK_FONT_Medium(17);
    loanScuessHeadLab.text = @"Your application has been submitted";
    loanScuessHeadLab.numberOfLines = 0;
    [self.view addSubview:loanScuessHeadLab];
    [loanScuessHeadLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.top.equalTo(@(DK_IsWidthScale(96)+DK_SafeAreaTop));
        make.width.equalTo(@(DK_IsWidthScale(160)));
        make.height.equalTo(@(DK_IsWidthScale(48)));
    }];
    UIImageView* loanScuessImgView = [[UIImageView alloc] init];
    loanScuessImgView.userInteractionEnabled = YES;
    loanScuessImgView.image = DK_GetImage(@"dk_LoanDetailCenterIcon");
    [self.view addSubview:loanScuessImgView];
    [loanScuessImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.top.equalTo(loanScuessHeadLab.mas_bottom).offset(DK_IsWidthScale(26));
        make.width.equalTo(@(DK_IsWidthScale(140)));
        make.height.equalTo(@(DK_IsWidthScale(101)));
    }];
    UILabel *loanScuessAlertLab = [[UILabel alloc] init];
    loanScuessAlertLab.textColor = DK_Hex(@"#999999");
    loanScuessAlertLab.font = DK_FONT_Regular(13);
    loanScuessAlertLab.text = @"The audit results will be updated within 24 hours.Please log in to the app to check.";
    loanScuessAlertLab.textAlignment = NSTextAlignmentCenter;
    loanScuessAlertLab.numberOfLines = 0;
    [self.view addSubview:loanScuessAlertLab];
    [loanScuessAlertLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.top.equalTo(loanScuessImgView.mas_bottom).offset(DK_IsWidthScale(29));
        make.left.equalTo(@(DK_IsWidthScale(36)));
        make.right.equalTo(@(-DK_IsWidthScale(36)));
    }];
    UIButton * dk_LoanScuessAgreementBtn = [[UIButton alloc] init];
    [dk_LoanScuessAgreementBtn setTitle:@"《Privacy Agreement》" forState:UIControlStateNormal];
    [dk_LoanScuessAgreementBtn setTitleColor:DK_Hex(@"#CCCCCC") forState:UIControlStateNormal];
    dk_LoanScuessAgreementBtn.titleLabel.font = DK_FONT_Regular(12);
    [dk_LoanScuessAgreementBtn addTarget:self action:@selector(CheckAgreement) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:dk_LoanScuessAgreementBtn];
    [dk_LoanScuessAgreementBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.bottom.equalTo(@(-DK_IsWidthScale(80)-DK_SafeAreaBottom));
        make.height.equalTo(@(DK_IsWidthScale(17)));
    }];
    //next
    self.dk_LoanScuessBtn = [[UIButton alloc] init];
    [self.dk_LoanScuessBtn setTitle:@"OK" forState:UIControlStateNormal];
    [self.dk_LoanScuessBtn setTitleColor:DK_Hex(@"#FFFFFF") forState:UIControlStateNormal];
    self.dk_LoanScuessBtn.titleLabel.font = DK_FONT_Semibold(16);
    [self.dk_LoanScuessBtn setBackgroundImage:DK_GetImage(@"dk_registerNextSelectBg") forState:UIControlStateNormal];
    [self.dk_LoanScuessBtn addTarget:self action:@selector(goLoanScuess) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.dk_LoanScuessBtn];
    [self.dk_LoanScuessBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(DK_IsWidthScale(30)));
        make.right.equalTo(@(-DK_IsWidthScale(30)));
        make.height.equalTo(@(DK_IsWidthScale(50)));
        make.bottom.equalTo(dk_LoanScuessAgreementBtn.mas_top).offset(-DK_IsWidthScale(20));
    }];
    [self showScoreView];
}
- (void)showScoreView{
    if(self.isShowScore){
        [DKHomeLoanScoreAlertView dk_ShowLoanScoreAlertView:self.view complete:^{
                       
        }];
    }
}
- (void)goBack{
    [self.navigationController popToRootViewControllerAnimated:YES];
}
- (void)goLoanScuess{
    [self.navigationController popToRootViewControllerAnimated:YES];
}
- (void)CheckAgreement{
    DKWebViewController * dk_WebViewCtrl = [[DKWebViewController alloc] initWithUrl:DK_PrivacyAgreement withIsNavBar:YES];
    [self.navigationController pushViewController:dk_WebViewCtrl animated:YES];
}
@end
